<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class Refund extends Model
{
    public function school()
    {
        return $this->hasOne(School::class,'id','school_id')->bind(['school_name'=>'name']);
    }

    public function invoice()
    {
        return $this->hasOne(Invoice::class,'id','invoice_id')->field('id,number');
    }

    public function student()
    {
        return $this->hasOne(Student::class,'id','student_id')->field('id,number');
    }

    public function payment()
    {
        return $this->hasOne(Payment::class,'id','payment')->field('id,name');
    }

    public function getItemAttr(string $name)
    {
        if(!empty($name)){
            return json_decode($name,true);
        }
        return $name;
    }
}
